/**
 * 0496
 *  
 * @Author : roryrywang
 * @DateTime : 2024/8/14 23:20
 */

#include <iostream>
#include <vector>
#include "unordered_map"
#include "stack"

using namespace std;

class Solution {
public:
    vector<int> nextGreaterElement(vector<int> &nums1, vector<int> &nums2) {
        unordered_map<int, int> map;
        stack<int> st;
        for (int i = nums2.size() - 1; i >= 0; --i) {
            while (!st.empty()) {
                if (nums2[i] < nums2[st.top()]) break;
                st.pop();
            }
            if (st.empty()) {
                map[nums2[i]] = -1;
            } else {
                map[nums2[i]] = nums2[st.top()];
            }
            st.push(i);
        }
        vector<int> res(nums1.size());
        for (int i = 0; i < nums1.size(); ++i) {
            res[i] = map[nums1[i]];
        }
        return res;
    }
};

int main() {

    return 0;
}